package com.woniu.mapper;

import com.woniu.pojo.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.vo.CommentVo;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Yellow Docker
 * @since 2022-11-21
 */
public interface CommentMapper extends BaseMapper<Comment> {

    @Select("select c.* from c_comment c,c_order_item o where c.order_id=o.id and o.product_id=#{id}")
    @ResultType(Comment.class)
    List<Comment> getServiceComment(Integer id);

    @Select("select c.* from c_comment c,c_order_item o where c.order_id=o.id and o.shop_id=#{id}")
    @ResultType(Comment.class)
    List<Comment> getShopComment(Integer id);

    @Select("select avg(c.level),o.shop_id from  c_comment c,c_order_item o where c.order_id = o.id" +
            "and c.create_time >= #{date} GROUP BY o.shop_id ")
    @ResultType(CommentVo.class)
    List<CommentVo> getShopAvgComment(Date date);
}
